#ifndef f_audio_decoder_h_
#define f_audio_decoder_h_

#include <windows.h>
#include <mmsystem.h>


#define AUDIO_STATUS_NONE		0
#define AUDIO_STATUS_PLAY		1
#define AUDIO_STATUS_BUFFERING	2
#define AUDIO_STATUS_SKIP		3
#define AUDIO_STATUS_CONNECTING 4


class CAudioDecoder
{
public:
	CAudioDecoder():
	  m_cRef(1)
	{};

	virtual ~CAudioDecoder()
	{};

	virtual const WAVEFORMATEX& Format() const = 0;
//irtual const WAVEFORMATEX* Format() const = 0;
	virtual DWORD Decode(BYTE *from, BYTE *to) = 0;
	virtual bool Open(const WAVEFORMATEX & required_format) = 0;
	virtual long StreamLen() const = 0;

	ULONG AddRef();
	ULONG Release();

private:
	LONG m_cRef;
};


inline ULONG CAudioDecoder::AddRef()
{
	return ::InterlockedIncrement(&m_cRef);
}

inline ULONG CAudioDecoder::Release()
{
	ULONG const ulRef = ::InterlockedDecrement( &m_cRef );
	if (0 == ulRef)
		delete this;
	return ulRef;
}


#endif